//
//  EGaddressCell.m
//  Orchard
//
//  Created by ios001 on 16/8/21.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "EGaddressCell.h"
#import "EGShopCartManager.h"

@interface EGaddressCell()

@property (nonatomic,strong) UIView      *addressView;

@property (nonatomic,strong) UILabel     *consigneeLable;

@property (nonatomic,strong) UILabel     *phoneNumLable;

@property (nonatomic,strong) UILabel     *addressLabel;

@property (nonatomic,strong) UIButton    *editBtn;

@property (nonatomic,strong) UIImageView *IndicatorImg;

@property (nonatomic,strong) UIImageView *lineImg;

@property (nonatomic,strong)   UIImageView *bottomLineImg;
@end

@implementation EGaddressCell

- (void)layoutSubviews{
    [self.contentView addSubview:self.addressView];
    
//    self.separatorInset =  UIEdgeInsetsMake(0, 0, 0, 0);
    
    [self.addressView addSubview:self.consigneeLable];
    [self.addressView addSubview:self.phoneNumLable];
    [self.addressView addSubview:self.addressLabel];
    [self.addressView addSubview:self.editBtn];
    [self.editBtn addTarget:self action:@selector(editBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.addressView addSubview:self.IndicatorImg];
    [self.addressView addSubview:self.lineImg];
    [self.addressView addSubview:self.bottomLineImg];
    [self.addressView makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.leading.trailing.equalTo(self.contentView);
    }];
    [self.consigneeLable makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.contentView).offset(8);
        make.top.equalTo(self.contentView).offset(12);
    }];
    [self.phoneNumLable makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.consigneeLable.leading);
        make.top.equalTo(self.consigneeLable.bottom).offset(5);
    }];
    [self.addressLabel makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.phoneNumLable.leading);
        make.bottom.equalTo(self.contentView).offset(-12);
    }];
    
    [self.editBtn makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.trailing.equalTo(self.IndicatorImg).offset(-20);
    }];
    
    [self.IndicatorImg makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.trailing.equalTo(self.contentView).offset(-15);
    }];
    
    [self.lineImg makeConstraints:^(MASConstraintMaker *make) {
        make.top.trailing.leading.equalTo(self);
    }];
    
    [self.bottomLineImg makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.leading.trailing.equalTo(self);
    }];
}

- (IBAction)editBtnClick:(id)sender{
    EGShopCartManager *manager = [EGShopCartManager sharedInstance];


}



- (UIView *)addressView{
    if (_addressView == nil) {
        _addressView = [[UIView alloc] init];
        _addressView.backgroundColor = ThemeColor;
    }
    return _addressView;
}
- (UILabel *)consigneeLable{
    if (_consigneeLable == nil) {
        _consigneeLable = [[UILabel alloc] init];
        _consigneeLable.font = [UIFont systemFontOfSize:12];
        _consigneeLable.text = @"收  货  人    维尼的小熊先生(死数据)";
    }
    return _consigneeLable;
}

- (UILabel *)phoneNumLable{
    if (_phoneNumLable == nil) {
        _phoneNumLable = [[UILabel alloc] init];
        _phoneNumLable.text = @"电        话    18833331111";
        _phoneNumLable.font = [UIFont systemFontOfSize:12];
    }
    return _phoneNumLable;
}

- (UILabel *)addressLabel{
    if (_addressLabel == nil) {
        _addressLabel = [[UILabel alloc] init];
        _addressLabel.text = @"收货地址    火星";
        _addressLabel.font = [UIFont systemFontOfSize:12];
    }
    return _addressLabel;
}

- (UIButton *)editBtn{
    if (_editBtn == nil) {
        _editBtn = [[UIButton alloc] init];
        [_editBtn setTitle:@"修改" forState:UIControlStateNormal];
        [_editBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        _editBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    }
    return _editBtn;
}

- (UIImageView *)IndicatorImg{
    if (_IndicatorImg == nil) {
        _IndicatorImg = [[UIImageView alloc] init];
        _IndicatorImg.image = [UIImage imageNamed:@"icon_go"];
    }
    return _IndicatorImg;
}

- (UIImageView *)lineImg{
    if (_lineImg == nil) {
        _lineImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"v2_shoprail"]];
    }
    return _lineImg;
}

- (UIImageView *)bottomLineImg{
    if (_bottomLineImg == nil) {
        _bottomLineImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"v2_shoprail"]];
    }
    return _bottomLineImg;
}


@end
